﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using System.Net.Security;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WeiTap.Web;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (Console.ReadLine()=="1")
            {
                var url =
                    "http://mp.weixin.qq.com/s?timestamp=1487916789&src=3&ver=1&signature=uIKJJdHq7-m*NF-tp5Pt1qXyOScnw9OILtGSziEKqFTrLOAPZ8PRgdByPE7Ndp-Y4yGonC8-L3i9A-iFita2f2tHYHvegHD6*Mz7BvchJ9gr12sq84WFncss-dIC29k6byZ4TGH0z-Bz8rJ-TZsg0OgzeJN-f5yQW4501X2P2Tc=";
                url = "http://weixin.sogou.com/weixin?type=1&query=%e6%97%b6%e4%ba%8b%e8%b5%84%e8%ae%af&page=1";
                var www = new HttpFire(url);
                www.Headers.AutoAddDefaultHeaders = true;
                www.Headers.Referer = url;
                www.Method = HttpRequestMethod.Get;
                //www.Headers.AcceptLanguage = "zh-cn";
                //www.Body.Wirte(Encoding.UTF8.GetBytes("{'a':1}"));
                //           www.Body.AddModel(new { a = 1, b = "fdsfdas", c = new { d = true, e = DateTime.Now, f = new[] { 1, 2, 3, 4, 5 } } });
                var str = www.GetString();
                var str1 = "";
                UserEntity.Request(url,out str1);
                //Console.WriteLine(str);
                Trace.Flush();
            }
            Console.ReadLine();
        }
    }

    public class UserEntity
    {
        public int Age { get; set; }
        public int Year { get; }

        public UserEntity()
        {
            Year = 1000;
        }
        public static string Request(string url, out string html, string method = "GET")
        {
            

            try
            {
                
               var myRequest = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = method;
                myRequest.KeepAlive = true;
                myRequest.Timeout = 10000;
                //响应流
                var myResponse = (HttpWebResponse)myRequest.GetResponse();
                var sRead = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                html = sRead.ReadToEnd();
            }
            catch (Exception ex)
            {
                html = ex.Message;
                return ex.Message;
            }
            
            return "";
        }
    }
}
